package com.ykq.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ykq.dao.EmpDao;
import com.ykq.pojo.Emp;
import com.ykq.service.EmpService;
import com.ykq.vo.EmpVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: vue_axios_ssm
 * @description:
 * @author: 闫克起2
 * @create: 2023-05-10 10:44
 **/
@Service
public class EmpServiceImpl implements EmpService {

    @Autowired
    private EmpDao empDao;

    public List<Emp> queryAll() {
        return empDao.findAll();
    }

    public int deleteById(Integer id) {
        int row=empDao.delete(id);
        return row;
    }

    public int save(Emp emp) {
        int row=empDao.insert(emp);
        return row;
    }

    public int update(Emp emp) {
        int row=empDao.update(emp);
        return row;
    }

    public PageInfo<Emp> queryAll(Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        List<Emp> all = empDao.findAll();
        //把查询的结果封装到Page对象中。
        PageInfo<Emp> pageInfo=new PageInfo<Emp>(all);
        return pageInfo;
    }

    public PageInfo<Emp> queryAll(Integer currentPage, Integer pageSize, EmpVo empVo) {
        PageHelper.startPage(currentPage,pageSize);
        List<Emp> all = empDao.findAllByCondition(empVo);
        //把查询的结果封装到Page对象中。
        PageInfo<Emp> pageInfo=new PageInfo<Emp>(all);
        return pageInfo;
    }
}











